package com.rm.dubbo;

import com.alibaba.dubbo.rpc.RpcContext;
import com.rm.dubbo.demo.ApiDemoTest;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) throws InterruptedException, ExecutionException {
        ApplicationContext
                context = new ClassPathXmlApplicationContext("spring/application-consumer.xml");
        ApiDemoTest demoTest = (ApiDemoTest) context.getBean("apiDemoTest");
        String admin = demoTest.login("admin", "123");
        Future<String> future = RpcContext.getContext().getFuture();
        System.out.println("main:" + admin);
        System.out.println("结果:"+future.get()); // 阻塞等待结果
        System.out.println("=========");

    }
}
